import uuid
import wmi


class Mac:

    @staticmethod
    def get_mac_address():
        c = wmi.WMI()
        macAddrs = []
        for s in c.Win32_NetworkAdapter():
            if s.MACAddress != None and s.PhysicalAdapter and s.AdapterType:
                macAddrs.append(s.MACAddress)
                print(s)
        sorted_mac = sorted(macAddrs)
        mac = ""
        for m in sorted_mac:
            mac += m + "_"
        return mac[:-1]

    @staticmethod
    def get_pc_mac_address():
        """
        获取电脑mac地址
        :return: 电脑mac地址,如：f8a2d60123456
        """
        # print("\n=========    获取电脑mac地址   =========")
        global s
        import wmi

        s = wmi.WMI()

        network = []
        for nw in s.Win32_NetworkAdapterConfiguration(IPEnabled=1):
            network.append({"MAC": nw.MACAddress, "ip": nw.IPAddress})

        MACAddress = str(nw.MACAddress).lower()
        # print("MACAddress={}".format(MACAddress))
        # print(network)
        return MACAddress


# print(Mac.get_pc_mac_address())
# print(Mac.load_mac())
